<?php

/**
 * This is the model class for table "uad.smihistoricos".
 *
 * The followings are the available columns in table 'uad.smihistoricos':
 * @property string $id
 * @property integer $id_afiliado_sumar
 * @property string $clave_beneficiario
 * @property string $activo
 * @property string $embarazada
 * @property string $fum
 * @property string $fecha_diagnostico_embarazo
 * @property string $fecha_probable_parto
 * @property string $motivo_baja
 * @property string $mensaje_baja
 * @property string $periodo
 *
 * The followings are the available model relations:
 * @property Sumar $idAfiliadoSumar
 */
class Smihistoricos extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'uad.smihistoricos';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('id_afiliado_sumar, clave_beneficiario, activo, embarazada, periodo', 'required'),
			array('id_afiliado_sumar', 'numerical', 'integerOnly'=>true),
			array('activo, embarazada', 'length', 'max'=>1),
			array('motivo_baja', 'length', 'max'=>10),
			array('mensaje_baja', 'length', 'max'=>200),
			array('fum, fecha_diagnostico_embarazo, fecha_probable_parto', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, id_afiliado_sumar, clave_beneficiario, activo, embarazada, fum, fecha_diagnostico_embarazo, fecha_probable_parto, motivo_baja, mensaje_baja, periodo', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'idAfiliadoSumar' => array(self::BELONGS_TO, 'Sumar', 'id_afiliado_sumar'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'id_afiliado_sumar' => 'Id Afiliado Sumar',
			'clave_beneficiario' => 'Clave Beneficiario',
			'activo' => 'Activo',
			'embarazada' => 'Embarazada',
			'fum' => 'Fum',
			'fecha_diagnostico_embarazo' => 'Fecha Diagnostico Embarazo',
			'fecha_probable_parto' => 'Fecha Probable Parto',
			'motivo_baja' => 'Motivo Baja',
			'mensaje_baja' => 'Mensaje Baja',
			'periodo' => 'Periodo',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('id_afiliado_sumar',$this->id_afiliado_sumar);
		$criteria->compare('clave_beneficiario',$this->clave_beneficiario,true);
		$criteria->compare('activo',$this->activo,true);
		$criteria->compare('embarazada',$this->embarazada,true);
		$criteria->compare('fum',$this->fum,true);
		$criteria->compare('fecha_diagnostico_embarazo',$this->fecha_diagnostico_embarazo,true);
		$criteria->compare('fecha_probable_parto',$this->fecha_probable_parto,true);
		$criteria->compare('motivo_baja',$this->motivo_baja,true);
		$criteria->compare('mensaje_baja',$this->mensaje_baja,true);
		$criteria->compare('periodo',$this->periodo,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Smihistoricos the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
